<template>
  <div class="recipes">
    <section class="hero-banner">
      <div class="banner-content">
        <h1 class="banner-title">端午美食</h1>
        <p class="banner-subtitle">品味传统，感受端午</p>
      </div>
    </section>

    <section class="recipes-container">
      <div class="container">
        <div class="section-header">
          <h2 class="section-title">端午特色美食</h2>
          <p class="section-description">探索端午节的传统美食及其制作方法</p>
        </div>

        <div class="recipes-tabs">
          <button 
            v-for="(tab, index) in tabs" 
            :key="index" 
            @click="activeTab = index"
            :class="{ active: activeTab === index }"
          >
            {{ tab }}
          </button>
        </div>

        <div class="recipes-content">
          <transition name="fade" mode="out-in">
            <div v-if="activeTab === 0" class="recipes-grid">
              <div v-for="(recipe, index) in zongziRecipes" :key="index" class="recipe-card">
                <div class="recipe-image-container">
                  <img :src="recipe.image" :alt="recipe.name" class="recipe-image">
                </div>
                <div class="recipe-content">
                  <h3 class="recipe-title">{{ recipe.name }}</h3>
                  <p class="recipe-origin">{{ recipe.origin }}</p>
                  <div class="recipe-details">
                    <div class="recipe-time">
                      <i class="icon">⏱️</i> {{ recipe.time }}
                    </div>
                    <div class="recipe-difficulty">
                      <i class="icon">🔥</i> {{ recipe.difficulty }}
                    </div>
                  </div>
                  <button class="btn view-btn" @click="openRecipeModal(recipe)">查看食谱</button>
                </div>
              </div>
            </div>

            <div v-else-if="activeTab === 1" class="recipes-grid">
              <div v-for="(recipe, index) in otherRecipes" :key="index" class="recipe-card">
                <div class="recipe-image-container">
                  <img :src="recipe.image" :alt="recipe.name" class="recipe-image">
                </div>
                <div class="recipe-content">
                  <h3 class="recipe-title">{{ recipe.name }}</h3>
                  <p class="recipe-origin">{{ recipe.origin }}</p>
                  <div class="recipe-details">
                    <div class="recipe-time">
                      <i class="icon">⏱️</i> {{ recipe.time }}
                    </div>
                    <div class="recipe-difficulty">
                      <i class="icon">🔥</i> {{ recipe.difficulty }}
                    </div>
                  </div>
                  <button class="btn view-btn" @click="openRecipeModal(recipe)">查看食谱</button>
                </div>
              </div>
            </div>
          </transition>
        </div>
      </div>
    </section>

    <transition name="fade">
      <div v-if="showRecipeModal" class="recipe-modal-overlay">
        <div class="recipe-modal-container">
          <div class="recipe-modal-header">
            <h3>{{ selectedRecipe.name }}</h3>
            <button class="close-btn" @click="closeRecipeModal">&times;</button>
          </div>
          <div class="recipe-modal-body">
            <div class="recipe-modal-image-container">
              <img :src="selectedRecipe.image" :alt="selectedRecipe.name" class="recipe-modal-image">
              <div class="recipe-meta">
                <div><i class="icon">📍</i> {{ selectedRecipe.origin }}</div>
                <div><i class="icon">⏱️</i> {{ selectedRecipe.time }}</div>
                <div><i class="icon">🔥</i> {{ selectedRecipe.difficulty }}</div>
              </div>
            </div>
            <div class="recipe-modal-content">
              <div class="ingredients-section">
                <h4>食材</h4>
                <ul class="ingredients-list">
                  <li v-for="(ingredient, index) in selectedRecipe.ingredients" :key="index">
                    {{ ingredient }}
                  </li>
                </ul>
              </div>
              <div class="steps-section">
                <h4>制作步骤</h4>
                <ol class="steps-list">
                  <li v-for="(step, index) in selectedRecipe.steps" :key="index">
                    {{ step }}
                  </li>
                </ol>
              </div>
            </div>
          </div>
        </div>
      </div>
    </transition>
  </div>
</template>

<script>
export default {
  name: 'Recipes',
  data() {
    return {
      tabs: ['粽子食谱', '其他端午美食'],
      activeTab: 0,
      zongziRecipes: [
        {
          name: '嘉兴肉粽',
          origin: '浙江嘉兴',
          time: '3小时',
          difficulty: '中等',
          image: 'https://ts1.tc.mm.bing.net/th/id/R-C.7afd3985c66395d6ea586f9080fd7058?rik=JpHSOoNGhycouQ&riu=http%3a%2f%2fi2.chuimg.com%2f5900dad0a4424bf7a1d2d2a80fb13fc9_1280w_960h.jpg%3fimageView2%2f2%2fw%2f660%2finterlace%2f1%2fq%2f90&ehk=E%2frooufQfZRE2kOowLJHxS9EAj7ie%2b0Ti5YDDEdnOT4%3d&risl=&pid=ImgRaw&r=0',
          ingredients: [
            '糯米 500g',
            '五花肉 300g',
            '粽叶 20片',
            '棉线 适量',
            '酱油 3汤匙',
            '料酒 1汤匙',
            '白糖 1茶匙',
            '盐 适量'
          ],
          steps: [
            '糯米提前浸泡4小时，沥干水分后加入酱油、盐拌匀',
            '五花肉切块，用酱油、料酒、糖腌制2小时',
            '粽叶洗净后煮软，沥干水分备用',
            '取两片粽叶叠放，折成漏斗状',
            '放入一勺糯米，加入一块五花肉，再盖上一勺糯米',
            '将粽叶包裹严实，用棉线捆扎好',
            '将粽子放入锅中，加水没过粽子，大火煮开后转小火煮2小时',
            '关火后焖1小时即可食用'
          ]
        },
        {
          name: '广东咸蛋黄粽',
          origin: '广东',
          time: '4小时',
          difficulty: '中等',
          image: 'https://img.ugoshop.com/images/201805/1526165367778430858.jpg',
          ingredients: [
            '糯米 500g',
            '咸蛋黄 6个',
            '五花肉 200g',
            '绿豆 100g',
            '粽叶 20片',
            '棉线 适量',
            '五香粉 1茶匙',
            '酱油 3汤匙',
            '盐 适量'
          ],
          steps: [
            '糯米和绿豆分别浸泡4小时，沥干水分',
            '五花肉切块，用酱油、五香粉腌制2小时',
            '咸蛋黄用料酒浸泡10分钟去腥',
            '粽叶洗净煮软，沥干水分备用',
            '取两片粽叶叠放，折成漏斗状',
            '放入一勺糯米，加入绿豆、五花肉和半个咸蛋黄，再盖上一勺糯米',
            '将粽叶包裹严实，用棉线捆扎好',
            '将粽子放入锅中，加水没过粽子，大火煮开后转小火煮3小时',
            '关火后焖1小时即可'
          ]
        },
        {
          name: '北京豆沙粽',
          origin: '北京',
          time: '2.5小时',
          difficulty: '简单',
          image: 'https://m.360buyimg.com/mobilecms/s750x750_jfs/t1/183521/6/4960/123812/60a4c8ccE2b4597e7/186d3f95f3b29929.jpg',
          ingredients: [
            '糯米 500g',
            '红豆沙 300g',
            '粽叶 20片',
            '棉线 适量',
            '白糖 2汤匙',
            '植物油 1汤匙'
          ],
          steps: [
            '糯米浸泡4小时，沥干水分后加入白糖拌匀',
            '红豆沙分成小份，搓成球状',
            '粽叶洗净煮软，沥干水分备用',
            '取两片粽叶叠放，折成漏斗状',
            '放入一勺糯米，加入一个豆沙球，再盖上一勺糯米',
            '将粽叶包裹严实，用棉线捆扎好',
            '将粽子放入锅中，加水没过粽子，大火煮开后转小火煮1.5小时',
            '关火后焖30分钟即可'
          ]
        }
      ],
      otherRecipes: [
        {
          name: '雄黄酒',
          origin: '中国各地',
          time: '10分钟',
          difficulty: '简单',
          image: 'https://img95.699pic.com/element/40192/7248.png_860.png',
          ingredients: [
            '黄酒 500ml',
            '雄黄粉 5g',
            '冰糖 适量'
          ],
          steps: [
            '将黄酒倒入小锅中',
            '加入雄黄粉和冰糖',
            '小火加热至微沸，搅拌至冰糖溶解',
            '关火后稍晾凉即可饮用',
            '注意：雄黄酒不宜多饮，孕妇忌饮'
          ]
        },
        {
          name: '艾草煮鸡蛋',
          origin: '中国各地',
          time: '30分钟',
          difficulty: '简单',
          image: 'https://ksv-video-picture.cdn.bcebos.com/ecd3861245afb7ea51f8fe6b3535b82db36b666f.jpg?x-bce-process=image%2Fresize%2Cm_lfit%2Cw_640%2Ch_360',
          ingredients: [
            '鸡蛋 6个',
            '新鲜艾草 50g',
            '水 适量',
            '盐 少许'
          ],
          steps: [
            '鸡蛋洗净，艾草洗净备用',
            '锅中加水，放入艾草和鸡蛋',
            '大火煮开后转小火煮15分钟',
            '用勺子轻轻敲裂蛋壳，继续煮5分钟',
            '关火后浸泡10分钟，让鸡蛋充分吸收艾草香气',
            '去壳后即可食用'
          ]
        },
        {
          name: '五毒饼',
          origin: '北方地区',
          time: '1.5小时',
          difficulty: '中等',
          image: 'https://tse2-mm.cn.bing.net/th/id/OIP-C.eu9H9Mxph_Ka4566YHmodwHaEF?rs=1&pid=ImgDetMain',
          ingredients: [
            '中筋面粉 300g',
            '红豆沙 200g',
            '白糖 50g',
            '植物油 50ml',
            '酵母 3g',
            '温水 150ml',
            '食用色素 少许'
          ],
          steps: [
            '将酵母溶于温水，静置5分钟',
            '面粉中加入白糖、植物油和酵母水，揉成光滑面团',
            '面团发酵至两倍大',
            '将面团分成小剂子，包入豆沙馅',
            '将包好的面团压扁，用模具压出五毒图案',
            '用食用色素点缀图案',
            '放入蒸锅，大火蒸15分钟即可'
          ]
        }
      ],
      showRecipeModal: false,
      selectedRecipe: {}
    }
  },
  methods: {
    openRecipeModal(recipe) {
      this.selectedRecipe = recipe
      this.showRecipeModal = true
      document.body.style.overflow = 'hidden'
    },
    closeRecipeModal() {
      this.showRecipeModal = false
      document.body.style.overflow = 'auto'
    }
  }
}
</script>

<style scoped>
.hero-banner {
  background: linear-gradient(rgba(0, 0, 0, 0.6), rgba(0, 0, 0, 0.6)), 
              url('https://img95.699pic.com/photo/50176/1059.jpg_wh860.jpg');
  background-size: cover;
  background-position: center;
  height: 400px;
  display: flex;
  align-items: center;
  justify-content: center;
  text-align: center;
  color: white;
  margin-bottom: 60px;
}

.banner-title {
  font-size: 3.5rem;
  margin-bottom: 20px;
  text-shadow: 2px 2px 4px rgba(0, 0, 0, 0.5);
}

.banner-subtitle {
  font-size: 1.5rem;
  margin-bottom: 30px;
  text-shadow: 1px 1px 2px rgba(0, 0, 0, 0.5);
}

.recipes-container {
  padding: 0 20px 80px;
}

.section-header {
  text-align: center;
  margin-bottom: 50px;
}

.section-title {
  font-size: 2.5rem;
  color: var(--primary-color);
  margin-bottom: 15px;
  position: relative;
  display: inline-block;
}

.section-title::after {
  content: '';
  position: absolute;
  bottom: -10px;
  left: 50%;
  transform: translateX(-50%);
  width: 80px;
  height: 3px;
  background: var(--primary-color);
}

.section-description {
  font-size: 1.1rem;
  color: #666;
  max-width: 700px;
  margin: 0 auto;
}

.recipes-tabs {
  display: flex;
  justify-content: center;
  margin-bottom: 40px;
  border-bottom: 1px solid #ddd;
}

.recipes-tabs button {
  padding: 12px 25px;
  margin: 0 10px;
  background: none;
  border: none;
  border-bottom: 3px solid transparent;
  font-size: 1rem;
  font-weight: bold;
  color: #666;
  cursor: pointer;
  transition: all 0.3s ease;
}

.recipes-tabs button.active {
  color: var(--primary-color);
  border-bottom-color: var(--primary-color);
}

.recipes-tabs button:hover {
  color: var(--primary-color);
}

.recipes-content {
  min-height: 500px;
}

.recipes-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
  gap: 30px;
}

.recipe-card {
  background: white;
  border-radius: 10px;
  overflow: hidden;
  box-shadow: 0 5px 15px rgba(0, 0, 0, 0.1);
  transition: transform 0.3s ease, box-shadow 0.3s ease;
}

.recipe-card:hover {
  transform: translateY(-10px);
  box-shadow: 0 15px 30px rgba(0, 0, 0, 0.15);
}

.recipe-image-container {
  height: 200px;
  overflow: hidden;
}

.recipe-image {
  width: 100%;
  height: 100%;
  object-fit: cover;
  transition: transform 0.5s ease;
}

.recipe-card:hover .recipe-image {
  transform: scale(1.05);
}

.recipe-content {
  padding: 20px;
}

.recipe-title {
  font-size: 1.3rem;
  margin-bottom: 5px;
  color: var(--primary-color);
}

.recipe-origin {
  color: #666;
  font-size: 0.9rem;
  margin-bottom: 15px;
}

.recipe-details {
  display: flex;
  justify-content: space-between;
  margin-bottom: 20px;
  font-size: 0.9rem;
  color: #666;
}

.view-btn {
  width: 100%;
  padding: 10px;
  font-size: 0.9rem;
}

.recipe-modal-overlay {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0, 0, 0, 0.7);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
}

.recipe-modal-container {
  background: white;
  border-radius: 10px;
  width: 90%;
  max-width: 800px;
  max-height: 90vh;
  overflow-y: auto;
  box-shadow: 0 5px 30px rgba(0, 0, 0, 0.3);
}

.recipe-modal-header {
  padding: 20px;
  border-bottom: 1px solid #eee;
  display: flex;
  justify-content: space-between;
  align-items: center;
  position: sticky;
  top: 0;
  background: white;
  z-index: 1;
}

.recipe-modal-header h3 {
  margin: 0;
  color: var(--primary-color);
}

.close-btn {
  background: none;
  border: none;
  font-size: 1.5rem;
  cursor: pointer;
  color: #666;
}

.recipe-modal-body {
  padding: 20px;
}

.recipe-modal-image-container {
  position: relative;
  margin-bottom: 20px;
}

.recipe-modal-image {
  width: 100%;
  height: 300px;
  object-fit: cover;
  border-radius: 5px;
}

.recipe-meta {
  display: flex;
  justify-content: space-around;
  background: rgba(255, 255, 255, 0.8);
  padding: 10px;
  border-radius: 5px;
  margin-top: -40px;
  position: relative;
  z-index: 1;
}

.recipe-modal-content {
  display: grid;
  grid-template-columns: 1fr 2fr;
  gap: 30px;
}

.ingredients-section, .steps-section {
  margin-bottom: 20px;
}

.ingredients-section h4, .steps-section h4 {
  color: var(--primary-color);
  margin-bottom: 15px;
  font-size: 1.2rem;
  border-bottom: 1px solid #eee;
  padding-bottom: 10px;
}

.ingredients-list {
  list-style: none;
  padding: 0;
}

.ingredients-list li {
  margin-bottom: 8px;
  padding-left: 20px;
  position: relative;
}

.ingredients-list li::before {
  content: '•';
  color: var(--primary-color);
  position: absolute;
  left: 0;
}

.steps-list {
  padding-left: 20px;
}

.steps-list li {
  margin-bottom: 15px;
  line-height: 1.6;
}

@media (max-width: 768px) {
  .hero-banner {
    height: 300px;
  }
  
  .banner-title {
    font-size: 2.5rem;
  }
  
  .banner-subtitle {
    font-size: 1.2rem;
  }
  
  .section-title {
    font-size: 2rem;
  }
  
  .recipes-tabs {
    flex-direction: column;
    align-items: center;
  }
  
  .recipes-tabs button {
    width: 100%;
    margin: 5px 0;
    text-align: center;
    padding: 10px 0;
  }
  
  .recipe-modal-content {
    grid-template-columns: 1fr;
  }
}
</style>